<!DOCTYPE html>
<html>
<head>
    <title>{$platform.name}</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>

    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
<!--    <script src="/static/js/framework-ui.js"></script>-->
<!--    <script src="/static/js/framework-clientdata.js"></script>-->

    <!--弹框js-->
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <script src="/static/layui/layui.all.js"></script>
    <script src="/static/layui/layui.js"></script>
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/lay/modules/layer.js"></script>


    <!--    配置select多选相关-->
<!--    <script src="/static/layui/dist/xm-select.js"></script>-->


        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
        {if condition="$swidthStyle eq 0"}
    <link href="/static/css/pattern/public.css" rel="stylesheet"/>
    {else/}
    <link href="/static/css/default/public.css" rel="stylesheet"/>
    {/if}
    {/if}


    <script src="/static/js/jquery-2.1.1.js"></script>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main.css"/>
    <script type="text/javascript" src='//webapi.amap.com/maps?v=2.0&key=1b5095aca8acff10518bf883f334b2ad&plugin=AMap.ToolBar'></script>
    <script src="//webapi.amap.com/ui/1.1/main.js?v=1.1.1"></script>

</head>
<body>
<style>
    html, body{background-color:#FFF!important;}
    .modal-body{background-color:#fff;padding:15px}
    .page-header{margin-top:15px!important;}
    .geographic input{width:100px!important;float: left;margin-right:15px;}
    .config_img {
        width: 100px;
        margin-top: 15px;
    }
</style>

<div class="modal-body">


    <div class="page-header">
        <h3>修改幻灯片</h3>
    </div>

    <form class="form-horizontal layui-form">

        <div class="form-group">
            <label class="col-sm-1 control-label">*广告名称:</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="name" value="{$detail.name}" placeholder="广告名称" >
            </div>
        </div>



        <div class="form-group">
            <label class="col-sm-1 control-label">*幻灯片文件:</label>
            <div class="col-sm-4">
                <div class="input-group ">
                    <input type="text" id="thumb" name="path" value="{$detail.path}" class="form-control" autocomplete="off">
                    <span class="input-group-btn">
                        <button class="btn btn-default" id="upload" type="button" data-original-title="" title="">选择图片</button>
                    </span>
                </div>
                <img class="config_img thumb" src="{$detail.path}" >
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-1 control-label">链接地址:</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="link" value="{$detail.link}" placeholder="链接地址" >
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">备注:</label>
            <div class="col-sm-4">
                <textarea  name="remark"  placeholder="备注" class="layui-textarea" lay-verify="content">{$detail.remark}</textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">状态:</label>
            <div class="col-sm-4">
                <select name="status" >
                    {volist name="enable_status" id="vo"}
                    <option {if condition="$detail['status'] eq $key"} selected {/if} value="{$key}">{$vo}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-1 control-label">排序:</label>
            <div class="col-sm-4">
                <input type="text" class="form-control" name="sort" value="{$detail.sort}" placeholder="排序" >
                <p>数值越大越靠前</p>
            </div>
        </div>


        <input name="id" value="{$detail.id}" type="hidden">


    </form>
</div>
<div class="add_button">

    <div class="form-group">
        <label  class="col-sm-1 control-label"></label>
        <div class="col-sm-8">
            <a type="button" class="layui-btn layui-btn-primary" href="javascript:history.back(-1)"  >取消</a>
            <button type="button" class="layui-btn" id="newsave" >保存</button>
        </div>
    </div>
</div>


<script>
    var newModal = new yii.modal();

    $("#upload").click(function () {
        $(newModal.getid()).show();
        newModal.initialization({
            url: "{:URL('common/upload/index')}",
            type: "post",
            data:{
                type:'detail'
            }
        });
    });

    newModal.on("upload",function(data){
        var images = '';
        $(newModal.getid()).find("#data-area .newimages .active img").each(function () {
            images = $(this).attr('src');
            return false
        })
        $(newModal.getid()).hide();
        //$(".modal-backdrop").remove();
        //$('#nowMainProjectDataForm').modal('hide');
        $(newModal.getid()).find(".modal").hide();
        $("#thumb").val(images);
        $(".config_img").attr("src",images)
    });

    layui.use(['form','layedit','tree','util'], function() {
        var form = layui.form
            , layer = layui.layer;
        var layedit = layui.layedit;
        var  tree = layui.tree;
        var util = layui.util;




        $("#newsave").click(function () {
            var data = $("form").serializeArray();

            var community_id =  $('select[name="community_id"]').val();
            $.ajax({
                type:'post',
                url:"{:URL('admin/Banner/doBanner')}",
                data:data,
                dataType:'JSON',
                success:function (res) {
                    if(res.code!=0){
                        layer.alert(res.msg);
                    }else{
                        if(community_id==0){
                            community_id = -1;
                        }
                        window.location.href = "{:URL('admin/Banner/index')}?community_id="+community_id;
                    }
                },
                error:function (res) {
                    
                }
            });

        })



        layui.form.render('select');
        form.render();


    });
</script>

</body>
</html>